//
//  HomeViewController.m
//  AVGirlShow
//
//  Created by 张良 on 2017/10/17.
//  Copyright © 2017年 张良. All rights reserved.
//

#import "HomeViewController.h"
#import "NewsViewController.h"
#import "EZSlideView.h"

@interface HomeViewController ()

@end

@implementation HomeViewController
- (void)viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"News";
//    self.extendedLayoutIncludesOpaqueBars = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    
    NewsViewController * appleViewController = [[NewsViewController alloc] init];
    appleViewController.newsType = @"apple";
    
    NewsViewController * girlViewController = [[NewsViewController alloc] init];
    girlViewController.newsType = @"meinv";
    
    NewsViewController * kejiViewController = [[NewsViewController alloc] init];
    kejiViewController.newsType = @"keji";
    
    NewsViewController * junshiViewController = [[NewsViewController alloc] init];
    junshiViewController.newsType = @"military";
    
//    self.navigationController.navigationBarHidden = YES;
//    [self.navigationController setNavigationBarHidden:YES animated:YES];
    
    [self addChildViewController:appleViewController];
    [self addChildViewController:girlViewController];
    [self addChildViewController:kejiViewController];
    [self addChildViewController:junshiViewController];
    
//    NSArray *viewControllers = @[@{@"苹果":appleViewController},@{@"美女":girlViewController},@{@"科技":kejiViewController},@{@"军事":junshiViewController}];
//
    NSArray *viewControllers = @[appleViewController,girlViewController,kejiViewController,junshiViewController];
    NSArray *buttonsTexts = @[@"苹果",@"美女",@"科技",@"军事"];
    
//    CGFloat y = [[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.bounds.size.height;
//    CGFloat height = [UIScreen mainScreen].bounds.size.height - y - self.tabBarController.tabBar.bounds.size.height;
    
    
    CGFloat y = [[UIApplication sharedApplication] statusBarFrame].size.height;
    //+ self.navigationController.navigationBar.bounds.size.height;
    CGFloat height = [UIScreen mainScreen].bounds.size.height - y - self.tabBarController.tabBar.bounds.size.height;
    
//    NSLog(@"statusBar:%f,navigationBar:%f,tabBar:%f",[[UIApplication sharedApplication] statusBarFrame].size.height,self.navigationController.navigationBar.bounds.size.height,self.tabBarController.tabBar.bounds.size.height);
    
//    YCSlideView * view = [[YCSlideView alloc]initWithFrame:CGRectMake(0, y, [UIScreen mainScreen].bounds.size.width, height) WithViewControllers:viewControllers];
//    NSLog(@"YCSlideView:%f",view.bounds.size.height);
    
    NSArray *activeColors = @[
                             [UIColor colorWithRed:240/255.0 green:111/255.0 blue:134/255.0 alpha:1],
                             [UIColor colorWithRed:252/255.0 green:183/255.0 blue:104/255.0 alpha:1],
                             [UIColor colorWithRed:87/255.0 green:217/255.0 blue:160/255.0 alpha:1],
                             [UIColor colorWithRed:137/255.0 green:137/255.0 blue:137/255.0 alpha:1]
                             ];
    
//    EZSlideView *view = [[EZSlideView alloc] initWithFrame:CGRectMake(0, y, [UIScreen mainScreen].bounds.size.width, height) viewControllers:viewControllers normalColor:[UIColor blackColor] activeColors:activeColors buttonsBackgroundColor:[UIColor whiteColor] buttonsViewBackgroundColor:[UIColor whiteColor] buttonsFont:[UIFont systemFontOfSize:15] buttonsViewHeight:40 buttonsHeight:38 lineHeight:2 lineMarginTop:0 bottomLineColor:[UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1] bottomLineHeight:1 bottomLineMarginTop:1];
    
    EZSlideView *view = [[EZSlideView alloc] initWithFrame:CGRectMake(0, y, [UIScreen mainScreen].bounds.size.width, height) viewControllers:viewControllers buttonsTexts:buttonsTexts normalColor:[UIColor blackColor] activeColors:activeColors];
    
    view.switchType = 0;
    view.touchButtonsContentSlideAnimate = YES;
    view.lineWidth = 50;
    
    [self.view addSubview:[view makeView]];
//    NSLog(@"HomeView:%f",self.view.bounds.size.height);
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
